﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace NamazVakti
{
    public class Parameters
    {
        public static string DiyanetSorguSayfasi = @"http://www.diyanet.gov.tr/turkish/namazvakti/vakithes_namazvakti.asp";
        public static string DiyanetSonucSayfasi = @"http://www.diyanet.gov.tr/turkish/namazvakti/vakithes_namazsonuc.asp";

        public static string SelectedCountry = "TURKIYE";
        public static string SelectedCity = "ISTANBUL";
        public static string SelectedPeriod = "ISTANBUL";

        public static string FilePath
        {
            get
            {
                return Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), SelectedCity + "namazVakitleri.xml");
            }
        }

        public static void Load()
        {
            try
            {
                using (TextReader reader = new StreamReader(
                    Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), "config.config")))
                {
                    SelectedCity = reader.ReadToEnd();
                }
            }
            catch
            {
            }
        }

        public static void Save(string selectedCity)
        {
            try
            {
                if (string.IsNullOrEmpty(selectedCity)) return;
                SelectedCity = selectedCity;
                using (TextWriter writer = new StreamWriter(
                    Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), "config.config")))
                {
                    writer.Write(selectedCity);
                    writer.Flush();
                }
            }
            catch
            {
            }
        }
    }
}
